USE [dbdata]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Browser', @membername=N'MoneyMaster'
GRANT UPDATE ON [dbo].[accounts] TO [Creditor] AS [dbo]
GO
/*
use dbdata
GRANT SELECT ON [dbo].[phones] TO [Browser] AS [dbo]
GRANT SELECT ON [dbo].[accounts] TO [Browser] AS [dbo]
GRANT SELECT ON [dbo].[identificators] TO [Browser] AS [dbo]
GRANT SELECT ON [dbo].[identificator_sets] TO [Browser] AS [dbo]
GRANT SELECT ON [dbo].[users] TO [Browser] AS [dbo]
GO
*/
USE [dbproc]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Executer', @membername=N'MoneyMaster'
deny execute on sp_get_account_balance_by_login to Executer;
grant execute on sp_get_account_balance_by_login to Creditor;
grant execute on sp_add_Sum_for_account to Creditor;
grant execute on sp_add_deposit_account to Creditor;
grant execute on sp_remove_sum_to_deposit to Creditor;
GO

USE [management]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Browser', @membername=N'MoneyMaster'
GRANT INSERT ON [dbo].[users] TO [Creditor] AS [dbo]

USE [sms]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Browser', @membername=N'MoneyMaster'
GRANT INSERT ON [dbo].[answers] TO [Creditor] AS [dbo]
GRANT INSERT ON [dbo].[notifications] TO [Creditor] AS [dbo]

USE [meps]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Browser', @membername=N'MoneyMaster'
GRANT INSERT ON [Control].[errorlog] TO [Creditor] AS [dbo]

GO
USE [Services]
GO
CREATE ROLE [Creditor] AUTHORIZATION [dbo]
EXEC dbo.sp_addrolemember @rolename=N'Creditor', @membername=N'MoneyMaster'
EXEC dbo.sp_addrolemember @rolename=N'Browser', @membername=N'MoneyMaster'
GRANT INSERT ON [dbo].[Outputemails] TO [Creditor] AS [dbo]

GO



